#include <stdio.h>

int main(int argc, char *argv[])
{

    int year, month, day, sum = 0;
    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    scanf("%d %d %d", &year, &month, &day);

    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
    {
        days[1] = 29;
    }

    for (size_t i = 0; i < month - 1; i++)
    {
        sum += days[i];
    }

    sum += day;

    printf("%d", sum);

    return 0;
}